<template>
  <div class="chart-container1">
    <div id="myChart" ref="myChart" :style="{ width: '100%', height: '220px' }"></div>
  </div>
</template>
<script>
import echarts from "echarts";
export default {
  props: {
    form: {
      type: Object
    }
  },
  data() {
    return {
      totalCount: 0
    };
  },
  mounted() {
    this.drawCharts();
  },
  watch: {
    form: {
      handler(newVal, oldVal) {
        this.drawCharts();
      },
      deep: true
    }
  },
  methods: {
    drawCharts() {
      this.myChart = this.$echarts.init(this.$refs.myChart);
      this.myChart.setOption({
        xAxis: {
          type: 'category',
          splitLine: {
            show: false // 不显示网格线
          },
          data: this.form.date
        },
        yAxis: {
          type: 'value',
          splitLine: {
            show: false // 不显示网格线
          },
          // name: '单位（%）'
        },
        series: [
          {
            itemStyle: {
            //
            normal: {
              color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                //   { offset: 0, color: "rgba(255,255,255,0)" },
                { offset: 0.5, color: "#5087EC" }
              ])
            }
          },
            data: this.form.percent,
            type: 'line'
          }
        ]
      });
    },
  }
};
</script>

<style scoped lang='less'></style>
